package com.demo.service;

import com.alibaba.fastjson.JSON;
import com.demo.bean.CustomerDTO;
import com.demo.bean.UserDTO;
import com.demo.provider.UserProvider;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * CustomerService
 *
 * @author liujin
 * @date 2020/11/4 14:44
 */
@Slf4j
@Service
public class CustomerService {

    @Resource
    private UserProvider userProvider;

    public String customer(CustomerDTO dto) {
        /*try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/
        log.info("---> {}", "CustomerService.customer");
        System.out.println(dto);
        UserDTO userDTO = new UserDTO();
        userDTO.setName(dto.getName());
        userDTO.setAddress(dto.getAddress());
        userProvider.user(userDTO);

        return JSON.toJSONString(dto);
    }
}
